package com.suzus.medicineGraph.controller;

import com.suzus.medicineGraph.common.Result;
import com.suzus.medicineGraph.service.Neo4jService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/neo4j")
public class Neo4jController {

    @Autowired
    private Neo4jService neo4jService;

    @GetMapping("findAllRelationShips")
    public Result findAllRelationShips() {
        HashMap<String, List> JsonResult = neo4jService.findAllRelationShips();
        return Result.success(JsonResult);
    }

    @GetMapping("/findMedicineRelationShips/{medicine}")
    public Result findMedicineRelationShips(@PathVariable String medicine) {
        System.out.println("有请求进入");
        System.out.println(medicine);
        HashMap<String, ArrayList> JsonResult = neo4jService.findMedicineRelationShips(medicine);
        return Result.success(JsonResult);
    }

    @GetMapping("/findMedicineRelationShips")
    public Result findMedicineRelationShips1(@RequestParam String medicine) {
        System.out.println("有请求进入");
        System.out.println(medicine);
        HashMap<String, ArrayList> JsonResult = neo4jService.findMedicineRelationShips(medicine);
        return Result.success(JsonResult);
    }

    @GetMapping("findSymptomRelationShips/{symptom}")
    public Result findSymptomRelationShips(@PathVariable String symptom) {
        System.out.println("symptom is " + symptom);
        HashMap<String,ArrayList> JsonResult = neo4jService.findSymptomRelationShips(symptom);
        return Result.success(JsonResult);
    }

}
